package org.classdef.analyzer.info.constant;

/**
 * 
 * 方法常量信息
 *
 */
public class MethodRefInfo extends ConstantInfo {

	private short classIndex;
	private short nameAndTypeIndex;

	public MethodRefInfo(short tag, short classIndex, short nameAndTypeIndex) {
		super(tag);
		this.classIndex = classIndex;
		this.nameAndTypeIndex = nameAndTypeIndex;
	}

	@Override
	public Object getValue() {
		StringBuilder sb = new StringBuilder();
		sb.append("{");
		sb.append("\"class\":\"").append(getPool().get(classIndex).getValue())
				.append("\"");
		sb.append(",\"nameAndType\":\"")
				.append(getPool().get(nameAndTypeIndex).getValue()).append("\"");
		sb.append("}");
		return sb.toString();
	}

	/*
	 * （非 Javadoc）
	 * 
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		StringBuilder sb = new StringBuilder();
		sb.append("{");
		sb.append("\"tag\":").append(tag);
		sb.append(",\"classIndex\":").append(classIndex);
		sb.append(",\"nameAndTypeIndex\":").append(nameAndTypeIndex);
		sb.append("}");
		return sb.toString();
	}
}